package org.hawk.gwt.ppc.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Arrays;

import junit.framework.TestCase;

public class IOTestCase extends TestCase {
	private static final String MOCK1 = "This is the mock stream";
	private static final byte[] MOCK2 = new byte[]{124,-48,34,4,4,122,-5,-3,24,-23,4,2,-34,2};
	
	public void testFlowReader() throws IOException{
		StringWriter output = new StringWriter();
		IO.flow(new StringReader(MOCK1), output);
		assertEquals(MOCK1, output.toString());
	}
	
	public void testFlowStream() throws IOException{
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		IO.flow(new ByteArrayInputStream(MOCK2),output);
		assertTrue(Arrays.equals(MOCK2, output.toByteArray()));
	}
	
	public void testToString() throws IOException{
		assertEquals(MOCK1, IO.toString(new StringReader(MOCK1)));
	}
}
